package com.yanqu.road.server.manager.log;

import com.yanqu.road.entity.activity.twins.log.CrossTwinsPvpBattleLog;
import com.yanqu.road.logic.bussiness.log.LogBussiness;

import java.util.ArrayList;
import java.util.List;

public class CrossActivityLogMgr {

    private static List<CrossTwinsPvpBattleLog> logTwinsPvpAttackList;


    public static boolean init() {
        logTwinsPvpAttackList = new ArrayList<>();
        return true;
    }

    public static boolean save() {
        saveLogTwinsPvpBattle();
        return true;
    }


    public static void addLogTwinsPvpBattle(int activityId,int groupId, long userId, int bossId, long attackUserId, String attackValue, int prestige, int allPrestige, int isKill,String selfValue){
        CrossTwinsPvpBattleLog log = new CrossTwinsPvpBattleLog(activityId,groupId,userId,bossId,attackUserId,attackValue,prestige,allPrestige,isKill,selfValue);
        synchronized (logTwinsPvpAttackList){
            logTwinsPvpAttackList.add(log);
        }
    }

    private static void saveLogTwinsPvpBattle(){
        if(logTwinsPvpAttackList.size() > 0){
            List<CrossTwinsPvpBattleLog> list;
            synchronized (logTwinsPvpAttackList){
                list = new ArrayList<>(logTwinsPvpAttackList);
                logTwinsPvpAttackList.clear();
            }
            LogBussiness.addLogTwinsPvpBattleList(list);
        }
    }
}
